﻿@model IEnumerable<SimpleTaskManager.Domain.Entities.User>
@using System.Web.Helpers;

@{
    ViewBag.Title = "Users";
    ViewBag.ShowInactive = !ViewBag.ShowInactive;
    if (ViewBag.ShowInactive) {
        ViewBag.ShowAll = "Show All";
    } else {
        ViewBag.ShowAll = "Show only current employees";
    }
}

@using (Html.BeginForm())
{
    <input class="rightSideButton" type="hidden" name="showInactive" value="@ViewBag.ShowInactive" />
    <input class="rightSideButton" type="submit" value="@ViewBag.ShowAll" />
}
<h2>Users</h2>

<table  id="userTable">
<thead>
    <tr>
        <th>Name</th>
        <th>Position</th>
        <th>Status</th>
        <th>Address</th>
        <th>E-mail</th>
        <th>Phone</th>
        @if (ViewBag.ShowEdit) { <th>Action</th> }
    </tr>
</thead>
<tbody>
@foreach (var user in Model)
{ 
    <tr>
        <td>@Html.ActionLink(user.FirstName + " " + user.LastName, "Details", new { id = user.UserID })</td>
        <td>@Html.DisplayFor(item => user.Position)</td>
        <td>@Html.DisplayFor(item => user.Status)</td>
        <td>@user.Address <br /> @user.ZIP @user.City , @user.Country</td>
        <td>@Html.DisplayFor(item => user.Email)</td>
        <td>@Html.DisplayFor(item => user.Phone)</td>
        @if (ViewBag.ShowEdit) { <td>@Html.ActionLink("Edit", "Edit", new { id = user.UserID }) |
                                     @Html.ActionLink("Delete", "Delete", new { id = user.UserID })
                                 </td> }
    </tr>
}
</tbody>
</table>
<br  />
@if (ViewBag.ShowEdit) 
{
    @Html.ActionLink("Add New User", "Create")
}
<script type="text/javascript">
    $(document).ready(function () {
        $("#userTable").dataTable({ bJQueryUI: true, sPaginationType: "full_numbers" });
    }
);
</script>